package com.qidian.mes.qc.controller;

import com.qidian.mes.pojo.Iqc;
import com.qidian.mes.qc.service.IqcService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequestMapping("/iqc")
public class IqcController {
    @Autowired
    private IqcService iqcService;
    @GetMapping("/get")
    public MESResult get(Long iqcId) {
        return iqcService.queryById(iqcId);
    }

    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit, Iqc iqc){
        System.out.println("=========================="+iqc);
        return iqcService.list(page,limit,iqc);
    }
    @PostMapping("/save")
    public MESResult save(@RequestBody Iqc iqc) {
        System.out.println("=========================="+iqc);
        return iqcService.save(iqc);
    }
    //编辑
    @PutMapping("/update")
    public MESResult update(@RequestBody Iqc iqc)  {
        return iqcService.update(iqc);
    }

    @DeleteMapping("/{iqcId}")
    public MESResult deleteById(@PathVariable Long iqcId) {
        return iqcService.deleteByIqcId(iqcId);
    }
    @DeleteMapping("/deletes")
    public MESResult deletesByTemplateId(Long[] iqcId) {

        return iqcService.deletesByIqcId(iqcId);

    }

}
